﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HexagonWeb.DAL;
using HexagonWeb.IBIL;
using HexagonWeb.Models;

namespace HexagonWeb.BIL
{
    public class TicketService : BaseService<Ticket>, InterfaceTicketService
    {
         public TicketService() : base(RepositoryFactory.TicketRepository) { }

        public Ticket Find(string pnr)
         {
             return CurrentRepository.Find(u => u.PNR == pnr);
         }


        public IQueryable<Ticket> FindByUserID(int UserID, int pageIndex, int pageSize, out int totalRecord, int order)
         {
             bool _isAsc = true;
             string _orderName = string.Empty;
             switch (order)
             {
                 default:
                     _isAsc = true;
                     _orderName = "AirlineID";
                     break;
             }
             return CurrentRepository.FindPageList(pageIndex, pageSize, out totalRecord, u => u.UserID == UserID, _orderName, _isAsc);
         }

         public IQueryable<Ticket>  FindByAirlineID(int AirlineID, int pageIndex, int pageSize, out int totalRecord,int order)
         {
            bool _isAsc = true;
            string _orderName = string.Empty;
            switch (order)
            {
                default:
                    _isAsc = true;
                    _orderName = "ID";
                    break;
            }
            return CurrentRepository.FindPageList(pageIndex, pageSize, out totalRecord, u => u.AirlineID == AirlineID, _orderName, _isAsc);
         }
    }
}